﻿Jxstar.currentPage = function() {
	var config = {param:{},initpage:function(page, define){},eventcfg:{}};

	var baotypeData = Jxstar.findComboData('baotype');
	var yesnoData = Jxstar.findComboData('yesno');
	var moneytypeData = Jxstar.findComboData('moneytype');
	var projectjdData = Jxstar.findComboData('projectjd');
	var planyearData = Jxstar.findComboData('planyear');
	var plantype2Data = Jxstar.findComboData('plantype2');
	var planstatus2Data = Jxstar.findComboData('planstatus2');
	var planstatusData = Jxstar.findComboData('planstatus');

	var cols = [
	{col:{header:'计划包属性', width:28, sortable:true, align:'center',
		editable:false,
		editor:new Ext.form.ComboBox({
			store: new Ext.data.SimpleStore({
				fields:['value','text'],
				data: baotypeData
			}),
			emptyText: jx.star.select,
			mode: 'local',
			triggerAction: 'all',
			valueField: 'value',
			displayField: 'text',
			editable:false,
			value: baotypeData[0][0]
		}),
		renderer:function(value){
			for (var i = 0; i < baotypeData.length; i++) {
				if (baotypeData[i][0] == value)
					return baotypeData[i][1];
			}
		}}, field:{name:'money_plan__bao_type',type:'string'}},
	{col:{header:'计划编号', width:100, sortable:true}, field:{name:'money_plan__plan_code',type:'string'}},
	{col:{header:'项目名称', width:185, sortable:true}, field:{name:'money_plan__plan_name',type:'string'}},
	{col:{header:'*是否需要结转', width:116, sortable:true, defaultval:'0', align:'center',
		editable:true, hcss:'color:#0000ff;',
		editor:new Ext.form.ComboBox({
			store: new Ext.data.SimpleStore({
				fields:['value','text'],
				data: yesnoData
			}),
			emptyText: jx.star.select,
			mode: 'local',
			triggerAction: 'all',
			valueField: 'value',
			displayField: 'text',
			editable:false, allowBlank:false,
			value: yesnoData[0][0]
		}),
		renderer:function(value){
			for (var i = 0; i < yesnoData.length; i++) {
				if (yesnoData[i][0] == value)
					return yesnoData[i][1];
			}
		}}, field:{name:'money_plan__has_turn',type:'string'}},
	{col:{header:'项目类别', width:122, sortable:true, align:'center',
		editable:false,
		editor:new Ext.form.ComboBox({
			store: new Ext.data.SimpleStore({
				fields:['value','text'],
				data: moneytypeData
			}),
			emptyText: jx.star.select,
			mode: 'local',
			triggerAction: 'all',
			valueField: 'value',
			displayField: 'text',
			editable:false,
			value: moneytypeData[0][0]
		}),
		renderer:function(value){
			for (var i = 0; i < moneytypeData.length; i++) {
				if (moneytypeData[i][0] == value)
					return moneytypeData[i][1];
			}
		}}, field:{name:'money_plan__money_type',type:'string'}},
	{col:{header:'预计总投资(万元)', width:128, sortable:true, renderer:JxUtil.formatNumber(6)}, field:{name:'money_plan__plan_money',type:'float'}},
	{col:{header:'合同金额(万元)', width:100, sortable:true, renderer:JxUtil.formatNumber(6)}, field:{name:'money_plan__money_contract',type:'float'}},
	{col:{header:'已付款金额(万元)', width:130, sortable:true, hidden:true, renderer:JxUtil.formatNumber(6)}, field:{name:'money_plan__money_pay',type:'float'}},
	{col:{header:'截止上年底累计付款(万元)', width:182, sortable:true, defaultval:'0', align:'right',
		editable:true, hcss:'color:#3039b4;',
		editor:new Ext.form.NumberField({
			decimalPrecision:6, maxLength:12
		}),renderer:JxUtil.formatNumber(6)}, field:{name:'money_plan__sun_money1',type:'float'}},
	{col:{header:'今年截止统计月份实际付款(万元)', width:206, sortable:true, defaultval:'0', align:'right',
		editable:true, hcss:'color:#3039b4;',
		editor:new Ext.form.NumberField({
			decimalPrecision:6, maxLength:12
		}),renderer:JxUtil.formatNumber(6)}, field:{name:'money_plan__tran_money1',type:'float'}},
	{col:{header:'*今年剩余月份预计付款(万元)', width:183, sortable:true, defaultval:'0', align:'right',
		editable:true, hcss:'color:#0000ff;',
		editor:new Ext.form.NumberField({
			decimalPrecision:6, maxLength:12, allowBlank:false
		}),renderer:JxUtil.formatNumber(6)}, field:{name:'money_plan__tran_money2',type:'float'}},
	{col:{header:'今年预计付款(万元)', width:137, sortable:true, defaultval:'0', align:'right',
		editable:false,
		editor:new Ext.form.NumberField({
			decimalPrecision:6, maxLength:12
		}),renderer:JxUtil.formatNumber(6)}, field:{name:'money_plan__money_pay1',type:'float'}},
	{col:{header:'截止今年底累计付款额(万元)', width:185, sortable:true, defaultval:'0', align:'right',
		editable:false,
		editor:new Ext.form.NumberField({
			decimalPrecision:6, maxLength:12
		}),renderer:JxUtil.formatNumber(6)}, field:{name:'money_plan__sun_money',type:'float'}},
	{col:{header:'今年批复付款额(万元)', width:146, sortable:true, defaultval:'0', align:'right',
		editable:false,
		editor:new Ext.form.NumberField({
			decimalPrecision:6, maxLength:12
		}),renderer:JxUtil.formatNumber(6)}, field:{name:'money_plan__year_money',type:'float'}},
	{col:{header:'*下年计划付款(万元)', width:147, sortable:true, defaultval:'0', align:'right',
		editable:true, hcss:'color:#0000ff;',
		editor:new Ext.form.NumberField({
			decimalPrecision:6, maxLength:12, allowBlank:false
		}),renderer:JxUtil.formatNumber(6)}, field:{name:'money_plan__year_money1',type:'float'}},
	{col:{header:'下年计划实施内容', width:170, sortable:true, editable:true, hcss:'color:#3039b4;',
		editor:new Ext.form.TextField({
			maxLength:200
		})}, field:{name:'money_plan__year_content2',type:'string'}},
	{col:{header:'开工日期', width:100, sortable:true, editable:true, hcss:'color:#3039b4;',
		editor:new Ext.form.DateField({
			format: 'Y-m-d',
			minValue: '1900-01-01'
		}),
		renderer:function(value) {
			return value ? value.format('Y-m-d') : '';
		}}, field:{name:'money_plan__project_sdate',type:'date'}},
	{col:{header:'竣工日期', width:100, sortable:true, editable:true, hcss:'color:#3039b4;',
		editor:new Ext.form.DateField({
			format: 'Y-m-d',
			minValue: '1900-01-01'
		}),
		renderer:function(value) {
			return value ? value.format('Y-m-d') : '';
		}}, field:{name:'money_plan__project_edate',type:'date'}},
	{col:{header:'*当前形象进度', width:121, sortable:true, align:'center',
		editable:true, hcss:'color:#0000ff;',
		editor:new Ext.form.ComboBox({
			store: new Ext.data.SimpleStore({
				fields:['value','text'],
				data: projectjdData
			}),
			emptyText: jx.star.select,
			mode: 'local',
			triggerAction: 'all',
			valueField: 'value',
			displayField: 'text',
			editable:false, allowBlank:false,
			value: projectjdData[0][0]
		}),
		renderer:function(value){
			for (var i = 0; i < projectjdData.length; i++) {
				if (projectjdData[i][0] == value)
					return projectjdData[i][1];
			}
		}}, field:{name:'money_plan__project_process',type:'string'}},
	{col:{header:'授权形式', width:100, sortable:true, hidden:true}, field:{name:'money_plan__auth_type',type:'string'}},
	{col:{header:'预算年度', width:100, sortable:true, align:'center',
		editable:false,
		editor:new Ext.form.ComboBox({
			store: new Ext.data.SimpleStore({
				fields:['value','text'],
				data: planyearData
			}),
			emptyText: jx.star.select,
			mode: 'local',
			triggerAction: 'all',
			valueField: 'value',
			displayField: 'text',
			editable:false,
			value: planyearData[0][0]
		}),
		renderer:function(value){
			for (var i = 0; i < planyearData.length; i++) {
				if (planyearData[i][0] == value)
					return planyearData[i][1];
			}
		}}, field:{name:'money_plan__plan_year',type:'string'}},
	{col:{header:'申报部门', width:137, sortable:true}, field:{name:'money_plan__dept_name',type:'string'}},
	{col:{header:'项目负责人', width:100, sortable:true}, field:{name:'money_plan__project_user',type:'string'}},
	{col:{header:'是否上报国家局', width:100, sortable:true, align:'center',
		editable:false,
		editor:new Ext.form.ComboBox({
			store: new Ext.data.SimpleStore({
				fields:['value','text'],
				data: yesnoData
			}),
			emptyText: jx.star.select,
			mode: 'local',
			triggerAction: 'all',
			valueField: 'value',
			displayField: 'text',
			editable:false,
			value: yesnoData[0][0]
		}),
		renderer:function(value){
			for (var i = 0; i < yesnoData.length; i++) {
				if (yesnoData[i][0] == value)
					return yesnoData[i][1];
			}
		}}, field:{name:'money_plan__up_comp',type:'string'}},
	{col:{header:'国家局项目类别', width:128, sortable:true, align:'center',
		editable:false,
		editor:new Ext.form.ComboBox({
			store: new Ext.data.SimpleStore({
				fields:['value','text'],
				data: plantype2Data
			}),
			emptyText: jx.star.select,
			mode: 'local',
			triggerAction: 'all',
			valueField: 'value',
			displayField: 'text',
			editable:false,
			value: plantype2Data[0][0]
		}),
		renderer:function(value){
			for (var i = 0; i < plantype2Data.length; i++) {
				if (plantype2Data[i][0] == value)
					return plantype2Data[i][1];
			}
		}}, field:{name:'money_plan__money_type2',type:'string'}},
	{col:{header:'国家局项目状态', width:100, sortable:true, align:'center',
		editable:true, hcss:'color:#3039b4;',
		editor:new Ext.form.ComboBox({
			store: new Ext.data.SimpleStore({
				fields:['value','text'],
				data: planstatus2Data
			}),
			emptyText: jx.star.select,
			mode: 'local',
			triggerAction: 'all',
			valueField: 'value',
			displayField: 'text',
			editable:false,
			value: planstatus2Data[0][0]
		}),
		renderer:function(value){
			for (var i = 0; i < planstatus2Data.length; i++) {
				if (planstatus2Data[i][0] == value)
					return planstatus2Data[i][1];
			}
		}}, field:{name:'money_plan__plan_status2',type:'string'}},
	{col:{header:'建设内容及方案', width:100, sortable:true, hidden:true}, field:{name:'money_plan__plan_desc',type:'string'}},
	{col:{header:'父计划编号', width:100, sortable:true, hidden:true}, field:{name:'money_plan__plan_parentcode',type:'string'}},
	{col:{header:'计划批复金额(万元)', width:134, sortable:true, renderer:JxUtil.formatNumber(6)}, field:{name:'money_plan__check_money',type:'float'}},
	{col:{header:'投资计划批复文号', width:123, sortable:true, editable:true, hcss:'color:#3039b4;',
		editor:new Ext.form.TextField({
			maxLength:100
		})}, field:{name:'money_plan__check_fileno',type:'string'}},
	{col:{header:'立项批复日期', width:100, sortable:true, renderer:function(value) {
			return value ? value.format('Y-m-d') : '';
		}}, field:{name:'money_plan__project_checkdate',type:'date'}},
	{col:{header:'统计月份', width:100, sortable:true, renderer:function(value) {
			return value ? value.format('Y-m') : '';
		}}, field:{name:'money_plan__stat_month',type:'date'}},
	{col:{header:'计划状态', width:81, sortable:true, align:'center',
		editable:false,
		editor:new Ext.form.ComboBox({
			store: new Ext.data.SimpleStore({
				fields:['value','text'],
				data: planstatusData
			}),
			emptyText: jx.star.select,
			mode: 'local',
			triggerAction: 'all',
			valueField: 'value',
			displayField: 'text',
			editable:false,
			value: planstatusData[0][0]
		}),
		renderer:function(value){
			for (var i = 0; i < planstatusData.length; i++) {
				if (planstatusData[i][0] == value)
					return planstatusData[i][1];
			}
		}}, field:{name:'money_plan__plan_status',type:'string'}},
	{col:{header:'项目id', width:100, sortable:true, hidden:true}, field:{name:'money_plan__project_id',type:'string'}},
	{col:{header:'申报部门ID', width:100, sortable:true, hidden:true}, field:{name:'money_plan__dept_id',type:'string'}},
	{col:{header:'主键', width:100, sortable:true, hidden:true}, field:{name:'money_plan__plan_id',type:'string'}},
	{col:{header:'申报人ID', width:100, sortable:true, hidden:true}, field:{name:'money_plan__plan_userid',type:'string'}},
	{col:{header:'申报人', width:100, sortable:true, hidden:true}, field:{name:'money_plan__plan_user',type:'string'}},
	{col:{header:'项目负责人id', width:100, sortable:true, hidden:true}, field:{name:'money_plan__project_userid',type:'string'}}
	];
	
	config.param = {
		cols: cols,
		sorts: null,
		hasQuery: '1',
		isedit: '1',
		isshow: '1',
		funid: 'money_complete'
	};
	
	
	//定义包标志列	cols[0].col.header = '';	cols[0].col.width = 28;	cols[0].col.renderer = function(val, meta, rec) {		var html = '';		var parentId = rec.get('money_plan__plan_id');		var baotype = rec.get('money_plan__bao_type');		var isturn = '0';		var imgname = 'folder' + baotype + '.gif';		if (baotype == '1' || baotype == '2') {			html = '<img src="resources/images/exp/'+ imgname +'" style="cursor:pointer;" title="点击查看子计划" '+				   'onClick="JxPm.showSubPlan(\''+ parentId +'\', \'money_compsub\', \''+ isturn +'\', \'money_complete\');"></img>';		}		return html;	};		config.initpage = function(gridNode) {		var grid = gridNode.page;				//注册"今年剩余月份预计付款(万元)"编辑后事件，需要修改其它金额值		grid.on('afteredit', function(e){			if (e.field == 'money_plan__tran_money2') {				JxPm.calPlanMoney(e.record);			}		});	};		config.eventcfg = {		planTran: function(){			var records = this.grid.getSelectionModel().getSelections();			if (!JxUtil.selected(records)) return;						var self = this;			var hdcall = function() {				//取选择记录的主键值				var params = 'funid='+ self.define.nodeid;				for (var i = 0; i < records.length; i++) {					params += '&keyid=' + records[i].get(self.define.pkcol);				}				//设置请求的参数				params += '&pagetype=selgrid&eventcode=planTran';				//执行处理的内容				var endcall = function(data) {					//重新加载数据					self.grid.getStore().reload();										//刷新目标表格					var destGrid = self.grid.destGrid;					if (destGrid != null) {						destGrid.getStore().reload();					}				};				//发送请求				Request.postRequest(params, endcall);			};						Ext.Msg.confirm(jx.base.hint, '将对选择的投资计划进行结转，确定提交吗？', function(btn) {				if (btn == 'yes') hdcall();			});		},			statComp: function(){			this.createWindow();		},				exeStat: function(form) {						var params = 'funid=money_complete';			params += JxUtil.getFormValues(form, false);			params += '&pagetype=editgrid&eventcode=statcomp';						var self = this;			var endcall = function(data) {				var where_sql = 'plan_year = ? and dept_id like ?';				var where_value = JxUtil.getCurYear() + ';' + JxDefault.getOrgId() + '%';				var where_type = 'string;string';				var options = {where_sql:where_sql, where_value:where_value, where_type:where_type};				Jxstar.loadData(self.grid, options);			};			//发送请求			Request.postRequest(params, endcall);		},				//创建对话框		createWindow: function() {			var printForm = new Ext.form.FormPanel({				style: 'padding:20px;',				border: false,				frame: false,				baseCls: 'x-plain',				items:[					{xtype:'textfield', fieldLabel:'统计单位', name:'dept_name', readOnly:true, anchor:'100%', maxLength:50},					{xtype:'datefield', fieldLabel:'统计月份', name:'stat_month', format:'Y-m', allowBlank:false, 					 labelStyle:'color:#0000FF;', labelSeparator:'*', anchor:'100%', readOnly:false},					{xtype:'hidden', fieldLabel:'统计单位id', name:'dept_id', anchor:'100%'},					{xtype:'hidden', fieldLabel:'统计人', name:'stat_user', anchor:'100%'},					{xtype:'hidden', fieldLabel:'统计人id', name:'stat_userid', anchor:'100%'}				]			});						//添加缺省值			var form = printForm.getForm();			form.set('dept_id', JxDefault.getOrgId());			form.set('dept_name', JxDefault.getOrgName());						form.set('stat_month', JxDefault.getCurMonth());			form.set('stat_userid', JxDefault.getUserId());			form.set('stat_user', JxDefault.getUserName());						var self = this;			//创建对话框			var win = new Ext.Window({				title:	'统计付款金额',				layout:'fit',				width:350,				height:150,				resizable: false,				modal: true,				closeAction:'close',				items:[printForm],				buttons: [{					text:jx.base.ok,		//'确定'					handler:function(){						//数据校验						if (!form.isValid()) {							JxHint.alert(jx.event.datavalid);	//'请确保输入的数据正确完整！'							return;						}						self.exeStat(form);						win.close();					}				},{					text:jx.base.cancel,	//'取消'					handler:function(){win.close();}				}]			});			win.show();		}	};
		
	return new Jxstar.GridNode(config);
}